//
//  SpotsCollectionViewCell.m
//  littleLight's Project-A
//
//  Created by dllo on 16/5/26.
//  Copyright © 2016年 light. All rights reserved.
//

#import "SpotsCollectionViewCell.h"
#import <UIImageView+WebCache.h>
@implementation SpotsCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
        
    }
    return self;
}




- (void)createView
{
    self.avatar_mImage = [[UIImageView alloc] init];
    self.avatar_mImage.frame = CGRectMake(10, 10, 60, 60);
    self.avatar_mImage.layer.masksToBounds = YES;
    self.avatar_mImage.layer.cornerRadius = 30;
    [self.contentView addSubview:self.avatar_mImage];
    self.userLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 10, 200, 30)];
    self.userLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.userLabel];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 40, 200, 30)];
    self.nameLabel.font = [UIFont systemFontOfSize:14];
    self.nameLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.nameLabel];
    
    self.text = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, self.contentView.frame.size.width - 20, 40)];
    self.text.font = [UIFont systemFontOfSize:13];
    self.text.numberOfLines = 0;
    
    [self.contentView addSubview:self.text];
    
    self.cover_image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 120, self.contentView.frame.size.width , 170)];
    [self.contentView addSubview:self.cover_image];
    
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 300, self.contentView.frame.size.width /5 * 4, 30)];
    self.titleLabel.font = [UIFont systemFontOfSize:14];
    self.titleLabel.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.titleLabel];
    
    
    
    
}


- (void)setModel:(SpotsModel *)model
{
    _model = model;
    
    self.userLabel.text = _model.model.name;
    self.nameLabel.text = _model.name;
    
    [self.avatar_mImage sd_setImageWithURL:[NSURL URLWithString:_model.model.avatar_m]];

    self.text.text = _model.text;
    [self.cover_image sd_setImageWithURL:[NSURL URLWithString:_model.cover_image]];
    self.titleLabel.text = _model.title;
        if (_model.name.length == 0) {
            
           self.userLabel.frame = CGRectMake(80, 25, 200, 30);
            
           // self.userLabel.text = _model.model.name;
        }
    if (_model.name != 0) {
        self.userLabel.frame = CGRectMake(80, 10, 200, 30);
        self.nameLabel.frame = CGRectMake(80, 40, 200, 30);
    }
    

}





@end
